fix: correct cadModel positionOffset Z-axis for JLCPCB imports - #365
Open
mendarb wants to merge 1 commit into
Open
fix: correct cadModel positionOffset Z-axis for JLCPCB imports#365mendarb wants to merge 1 commit into
mendarb wants to merge 1 commit into
Conversation
…ports Two bugs in the Z-axis positioning of 3D models imported from EasyEDA/JLCPCB: 1. Z-offset unit parsing: bare numeric z values from EasyEDA SVG nodes were treated as mils, but they are actually in pixel units (1px = 10mil = 0.254mm), consistent with how x/y offsets are parsed via mil10ToMm(). 2. Z positioning logic: the centerZ calculation incorrectly added/subtracted half the model thickness (thicknessAlongWorldZ/2), causing models to float above or sink below the board surface. Simplified to position the model origin directly at the board surface (±t) plus the EasyEDA z-offset. Fixes tscircuit#123 /claim tscircuit#123 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #123
/claim #123
Z-offset unit parsing: Bare numeric
zvalues from EasyEDA SVG nodes were incorrectly treated as mils (mm("Xmil")), but they are actually in pixel units (1px = 10mil = 0.254mm). Now usesmil10ToMm()consistent with howxandyoffsets are already parsed.Z positioning logic: The
centerZcalculation incorrectly added/subtracted half the model thickness (thicknessAlongWorldZ / 2), causing 3D models to float above or sink below the board surface. Simplified to position the model origin directly at the board surface (±t) plus the EasyEDA z-offset, matching how EasyEDA models are actually authored.What was wrong
The
parseCadOffsetsFromSvgNodefunction usedmm("Xmil")for bare z values, whilexandyusedmil10ToMm(). EasyEDA uses pixel units (1px = 10mil) for all three axes, so the z conversion was off by a factor of 10.Additionally, the final Z positioning added half the model thickness to try to place the bottom of the model on the board surface, but this assumption was incorrect for many component orientations and caused visible misalignment.
Test plan
🤖 Generated with Claude Code